package dimensional.traveler.client;

import com.google.gwt.user.client.ui.RootPanel;

import dimensional.traveler.client.mvc.ControlledComposite;
import dimensional.traveler.client.screens.battlefield.Battlefield;
import dimensional.traveler.client.screens.characterclasschooser.CharacterClassChooserScreen;
import dimensional.traveler.client.screens.cinematic.CinematicScreen;
import dimensional.traveler.client.screens.gamemenu.GameMenuScreen;
import dimensional.traveler.client.screens.login.LoginScreen;
import dimensional.traveler.client.screens.missionend.MissionEndScreen;
import dimensional.traveler.client.screens.welcome.WelcomeScreen;
import dimensional.traveler.shared.model.missionSequence.Battle;
import dimensional.traveler.shared.model.missionSequence.CharacterClassChoice;
import dimensional.traveler.shared.model.missionSequence.Cinematic;
import dimensional.traveler.shared.model.missionSequence.MissionEndDetails;
import dimensional.traveler.shared.model.missionSequence.MissionSequence;

public class Mediator {

	private RootPanel rootPanel = RootPanel.get("application-container");
	
	public void displayLoginScreen() {
		displayScreen(new LoginScreen());
	}
	
	public void displayWelcomeScreen() {
		displayScreen(new WelcomeScreen());
	}
	
	public void displayMissionSequence(MissionSequence nextMissionSequence) {
		if (nextMissionSequence instanceof Cinematic){
			displayScreen(new CinematicScreen((Cinematic)nextMissionSequence));
		} else if (nextMissionSequence instanceof Battle){
			displayScreen(new Battlefield((Battle) nextMissionSequence));
		} else if (nextMissionSequence instanceof CharacterClassChoice){
			displayScreen(new CharacterClassChooserScreen());
		} else if (nextMissionSequence instanceof MissionEndDetails){
			displayScreen(new MissionEndScreen((MissionEndDetails)nextMissionSequence));
		}
	}
	
	public void displayGameMenuScreen() {
		displayScreen(new GameMenuScreen());
	}
	
	private void displayScreen(ControlledComposite screen){
		rootPanel.clear();
		screen.getController().setMediator(Mediator.this);
		rootPanel.add(screen);
	}
}
